package com.ruoyi.pcwl.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.ruoyi.pcwl.domain.query.HotelRoomQuery;
import com.ruoyi.pcwl.domain.HotelRoom;
import com.ruoyi.pcwl.mapper.HotelRoomMapper;
import com.ruoyi.pcwl.service.HotelRoomService;


/**
 * 商铺环境信息 业务接口实现
 */
@Service("hotelRoomService")
public class HotelRoomServiceImpl extends ServiceImpl<HotelRoomMapper, HotelRoom> implements HotelRoomService {


	/**
	 * 据条件查询记录数
	 */
	@Override
	public Integer findCountByParam(HotelRoomQuery reqParam) {
		QueryWrapper<HotelRoom> wrapper = new QueryWrapper<>();
		if (reqParam.getId()!=null)
			wrapper.eq("id",reqParam.getId());
		if (reqParam.getHotelId()!=null)
			wrapper.eq("hotel_id",reqParam.getHotelId());
		if (StringUtils.isNotEmpty(reqParam.getRoomName())) {
			wrapper.like("room_name", reqParam.getRoomName());
		}
		if (StringUtils.isNotEmpty(reqParam.getTel())) {
			wrapper.like("tel", reqParam.getTel());
		}
		if (StringUtils.isNotEmpty(reqParam.getUrl())) {
			wrapper.like("url", reqParam.getUrl());
		}
		if (StringUtils.isNotEmpty(reqParam.getTags())) {
			wrapper.like("tags", reqParam.getTags());
		}
		if (reqParam.getHot()!=null)
			wrapper.eq("hot",reqParam.getHot());
		if (reqParam.getMediaFileId()!=null)
			wrapper.eq("media_file_id",reqParam.getMediaFileId());
		if (StringUtils.isNotEmpty(reqParam.getPic())) {
			wrapper.like("pic", reqParam.getPic());
		}
		if (StringUtils.isNotEmpty(reqParam.getDetail())) {
			wrapper.like("detail", reqParam.getDetail());
		}
		if (StringUtils.isNotEmpty(reqParam.getUsername())) {
			wrapper.like("username", reqParam.getUsername());
		}
		if (StringUtils.isNotEmpty(reqParam.getStatus())) {
			wrapper.like("status", reqParam.getStatus());
		}
		if (StringUtils.isNotEmpty(reqParam.getRemark())) {
			wrapper.like("remark", reqParam.getRemark());
		}
		Long aLong = baseMapper.selectCount(wrapper);
		return aLong.intValue();
	}

	/**
	 * 根据条件查询列表
	 */
	@Override
	public IPage<HotelRoom> selectPage(HotelRoomQuery reqParam) {
		QueryWrapper<HotelRoom> wrapper = new QueryWrapper<>();
		if (reqParam.getId()!=null)
			wrapper.eq("id",reqParam.getId());
		if (reqParam.getHotelId()!=null)
			wrapper.eq("hotel_id",reqParam.getHotelId());
		if (StringUtils.isNotEmpty(reqParam.getRoomName())) {
			wrapper.like("room_name", reqParam.getRoomName());
		}
		if (StringUtils.isNotEmpty(reqParam.getTel())) {
			wrapper.like("tel", reqParam.getTel());
		}
		if (StringUtils.isNotEmpty(reqParam.getUrl())) {
			wrapper.like("url", reqParam.getUrl());
		}
		if (StringUtils.isNotEmpty(reqParam.getTags())) {
			wrapper.like("tags", reqParam.getTags());
		}
		if (reqParam.getHot()!=null)
			wrapper.eq("hot",reqParam.getHot());
		if (reqParam.getMediaFileId()!=null)
			wrapper.eq("media_file_id",reqParam.getMediaFileId());
		if (StringUtils.isNotEmpty(reqParam.getPic())) {
			wrapper.like("pic", reqParam.getPic());
		}
		if (StringUtils.isNotEmpty(reqParam.getDetail())) {
			wrapper.like("detail", reqParam.getDetail());
		}
		if (StringUtils.isNotEmpty(reqParam.getUsername())) {
			wrapper.like("username", reqParam.getUsername());
		}
		if (StringUtils.isNotEmpty(reqParam.getStatus())) {
			wrapper.like("status", reqParam.getStatus());
		}
		if (StringUtils.isNotEmpty(reqParam.getRemark())) {
			wrapper.like("remark", reqParam.getRemark());
		}
		return baseMapper.selectPage(reqParam.getPage(), wrapper);
	}

	/**
	 * 新增
	 */
	@Override
	public Integer add(HotelRoom bean) {
		return baseMapper.insert(bean);
	}

	/**
	 * 批量新增
	 */
	@Override
	public Integer addBatch(List<HotelRoom> listBean) {
		if (listBean == null || listBean.isEmpty()) {
			return 0;
		}
		return baseMapper.insertBatch(listBean);
	}

	/**
	 * 批量新增或者修改
	 */
//	@Override
//	public Integer addOrUpdateBatch(List<HotelRoom> listBean) {
//		if (listBean == null || listBean.isEmpty()) {
//			return 0;
//		}
//		return baseMapper.insertOrUpdateBatch(listBean);
//	}

	/**
	 * 多条件更新
	 */
//	@Override
//	public Integer updateByParam(HotelRoom bean, HotelRoomQuery param) {
//		return baseMapper.updateByParam(bean, param);
//	}

	/**
	 * 多条件删除
	 */
//	@Override
//	public Integer deleteByParam(HotelRoomQuery param) {
//		return baseMapper.deleteByParam(param);
//	}

	/**
	 * 根据Id获取对象
	 */
	@Override
	public HotelRoom getHotelRoomById(Long id) {
		return baseMapper.selectById(id);
	}

	/**
	 * 根据Id修改
	 */
	@Override
	public Integer updateHotelRoomById(HotelRoom bean) {
		return baseMapper.updateById(bean);
	}

	/**
	 * 根据Id删除
	 */
	@Override
	public Integer deleteHotelRoomById(Long id) {
		return baseMapper.deleteById(id);
	}
}
